//
// Created by cheng on 2021/02/08.
//

#include <iostream>
#include <string>
#define M 1000

using namespace std;

// 散列表
string hashMap[M];

// 散列表插入
void insert(string str);
// 散列表查找
bool find(string str);

// 将字符转化为数值
int getChar(const char& c);
// 将字符串转化为数值
long long getKey(const string& str);

int h1(int key) {return key % M;}
int h2(int key) {return 1+(key%(M-1));}


int main() {
    string command, str;
    cin >> command >> str;
    cout << getKey(str) << endl;
    if (command[0] == 'i') {
        insert(str);
    } else {
        if (find(str)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    cout << command << endl << str << endl;
}

void insert(string str) {
    auto key = getKey(str);

}

bool find(string str) {
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;;i++) {
        h = (h1(key) + i*h2(key)) % M;
        if (str.compare(hashMap[h])) return true;
        else if (hashMap[h].length() == 0) return false;
    }
    return false;
}

long long getKey(const string& str) {
    long long key = 0, p = 1;
    for(char i : str) {
        key += p*getChar(i);
        p *= 5;
    }
    return key;
}

int getChar(const char& c) {
    switch (c) {
        case'q' :
            return 1;
        case 'w':
            return 2;
        case 'e':
            return 3;
        case 'r' :
            return 4;
        default:
            return 0;
    }
}
